<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--引入easyui的样式 -->
<link rel="stylesheet"  type="text/css" href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css">
<link rel="stylesheet"  type="text/css" href="${pageContext.request.contextPath}/themes/icon.css">
<!-- js文件 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<title>Insert title here</title>
</head>
<script type="text/javascript">
//打开页面就加载当前设置的选课时间
	$(function(){
		
		$.ajax({
			url:"getTime",
			data:{},
			dataType:"json",
			success:function(data){
				$('#nowset').append("<label>"+data.cbtime+"——"+data.cetime+"</label>");
				
			}
			
			
		})
	})
	
	
	
	function setTime(){
		
		$(function(){
			
		var cbtime = $('#cbtime').datebox('getValue');
		var cetime = $('#cetime').datebox('getValue');
			
		$.ajax({
			type:"post",
				url:"setTime",
				data:{"cbtime":cbtime,"cetime":cetime},
				dataType:"text",
				success:function(data){
					
					if(data=="true"){
 						//提示窗口
 						$.messager.alert('提示','设置成功','info',function(){
 						    window.location.reload();
 						});
 						
 					}else{
 						$.messager.alert('提示','设置失败','info',function(){
 						    window.location.reload();
 						});
 						
 					}
				}
		})
		})
	}

</script>
<body>

		<div style="padding:5% 60px 20px 30%">
	   
	    		<div id="nowset">
	    		<label>当前设置：</label>
	    		</div>
	    		<div style="margin-top: 20px">
	    		<label>开始选课时间：</label>
	    		<input id="cbtime" class="easyui-datebox"  ></input>
	    		</div>
	    		<div style="margin-top: 20px">
	    		<label>结束选课时间：</label>
	    		<input id="cetime" class="easyui-datebox"  ></input>
	    		</div>
	  
	    <div style="margin-left: 32% ;margin-top: 5% ">
	    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="setTime()">确定</a>
	    	
	    </div>
	    </div>


</body>
</html>